import mongoengine

from academic.settings import MONGODB

class Policy(mongoengine.DynamicDocument):
    meta = {'collection': MONGODB.get('POLICY')}

    id = mongoengine.StringField(db_field='_id', max_length=50, primary_key=True)
    title = mongoengine.StringField(db_field='标题', max_length=100)
    unit = mongoengine.StringField(db_field='发布单位', max_length=50)
    keywords = mongoengine.StringField(db_field='关键词', max_length=50)
    introduction = mongoengine.StringField(db_field='简介', max_length=100)
    province = mongoengine.StringField(db_field='省份', max_length=50)
    data = mongoengine.StringField(db_field='时间', max_length=50)
    source = mongoengine.StringField(db_field='文件来源', max_length=50)

    def __str__(self):
        return "政策id" + str(self.id) + "\t 政策" + str(self.title)

class AwardGuide(mongoengine.DynamicDocument):
    meta = {'collection': MONGODB.get('AWARDSGUIDE')}

    id = mongoengine.StringField(db_field='_id', max_length=50, primary_key=True)
    year = mongoengine.StringField(db_field='年份', max_length=50)
    level = mongoengine.StringField(db_field='级别', max_length=50)
    name = mongoengine.StringField(db_field='奖项名称', max_length=50)
    data = mongoengine.StringField(db_field='申报时间', max_length=50)
    pattern = mongoengine.StringField(db_field='申报方式', max_length=50)
    unit = mongoengine.StringField(db_field='组织单位', max_length=50)
    material = mongoengine.StringField(db_field='申报材料', max_length=50, null=True)
    file = mongoengine.StringField(db_field='相关文件', max_length=50, null=True)
    recommendUnit = mongoengine.StringField(db_field='可推荐/提名单位', max_length=50, null=True)
    relation = mongoengine.StringField(db_field='与其他奖项关系', max_length=50, null=True)

    def __str__(self):
        return "奖项id" + str(self.id) + "\t 奖项" + str(self.name)

class Awards(mongoengine.DynamicDocument):
    meta = {'collection': MONGODB.get('AWARDS')}

    id = mongoengine.StringField(db_field='_id', max_length=50, primary_key=True)
    year = mongoengine.StringField(db_field='年份', max_length=50)
    awards = mongoengine.StringField(db_field='奖项', max_length=50)
    project = mongoengine.StringField(db_field='项目名称', max_length=50)
    level = mongoengine.StringField(db_field='奖项等级', max_length=50)
    participant = mongoengine.StringField(db_field='主要完成人', max_length=50)
    recommendUnit = mongoengine.StringField(db_field='提名/推荐单位', max_length=50, null=True)
    topical = mongoengine.StringField(db_field='获奖热点', max_length=50, null=True)
    unit = mongoengine.StringField(db_field='获奖单位', max_length=50, null=False)

    def __str__(self):
        return "奖项id" + str(self.id) + "\t 获奖项目" + str(self.project)

class AwardsDeclaration(mongoengine.DynamicDocument):
    meta = {'collection': MONGODB.get('DECLARATION')}

    id = mongoengine.StringField(db_field='_id', max_length=50, primary_key=True)
    unit = mongoengine.StringField(db_field='发布单位', max_length=50)
    data = mongoengine.StringField(db_field='发布时间', max_length=50)
    filename = mongoengine.StringField(db_field='文件名称', max_length=50)

class WinningNotice(mongoengine.DynamicDocument):
    meta = {'collection': MONGODB.get('ANNOUNCEMENT')}

    id = mongoengine.StringField(db_field='_id', max_length=50, primary_key=True)
    unit = mongoengine.StringField(db_field='发布单位', max_length=50)
    data = mongoengine.StringField(db_field='发布时间', max_length=50)
    filename = mongoengine.StringField(db_field='文件名称', max_length=50)

class PolicyInterpretion(mongoengine.DynamicDocument):
    meta = {"collection": MONGODB.get('POLICYINTER')}

    id = mongoengine.StringField(db_field='_id', max_length=50, primary_key=True)
    title = mongoengine.StringField(db_field='标题', max_length=100)
    introduction = mongoengine.StringField(db_field='简介', max_length=200)
    data = mongoengine.StringField(db_field='时间', max_length=50)
    unit = mongoengine.StringField(db_field='发布单位', max_length=50)
    province = mongoengine.StringField(db_field='省份', max_length=50)
    keywords = mongoengine.StringField(db_field='关键词', max_length=150)
    source = mongoengine.StringField(db_field='文件来源', max_length=150)
